package com.googlecode.mailnet.emf.netmodel.visualization.failure;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Shape;
import org.eclipse.gmf.runtime.notation.LineStyle;
import org.eclipse.swt.graphics.Color;

import com.googlecode.mailnet.emf.netmodel.visualization.ShapeDecorator;
import com.googlecode.mailnet.info.ILinkInfo;

public class FailureLinkDecorator extends ShapeDecorator {
	
	ILinkInfo linkInfo;
	Color okColor = new Color(null, 0, 255, 0);
	Color failureColor = new Color(null, 255, 0, 0);
	
	
	public FailureLinkDecorator(ILinkInfo linkInfo) {
		this.linkInfo = linkInfo;
	}
	
	public boolean outlineShape(Shape shape, Graphics g) {
		shape.setForegroundColor(linkInfo.isBroken() ? failureColor : okColor);
		shape.setLineStyle(linkInfo.isBroken() ? Graphics.LINE_DASH : Graphics.LINE_SOLID);
		shape.setLineWidth(1);
		return false;
	}
}
